/**
 * Project hdmap
 * @author shengjialiang
 * @version v1.0
 */


#ifndef _GENERALRENDEROBJECT_H
#define _GENERALRENDEROBJECT_H


#include "map_datarender/IRenderObject.h"
#include "map_datarender/DataRenderConfig.h"

namespace DataRender
{
	class MAP_DATARENDER_EXPORT CRenderObject : public IRenderObject
    {
    public:
        CRenderObject(osg::ref_ptr<osg::Group> in_pParentNode);

        virtual ~CRenderObject();

        virtual int& getSize();

        virtual bool& depthTest();

        virtual void setVisible(const bool& in_visible);

        virtual void setMatrix(const osg::Matrix& in_matrix);

        virtual void setAdjustMatrix(const osg::Matrix& in_adjustmatrix);

        virtual bool load();

        virtual bool render();

        virtual bool unload();

        virtual bool canRender(osg::Node* node, osg::NodeVisitor* nv, osgViewer::Viewer* viewer);

        virtual bool getData(osg::ref_ptr<osg::Vec3dArray>& inou_points, osg::ref_ptr<osg::Vec4Array>& inout_colors) = 0;
    protected:
        virtual osg::ref_ptr<osg::Node> createNode(osg::ref_ptr<osg::Vec3dArray>& in_points, osg::ref_ptr<osg::Vec4Array>& in_colors) = 0;
		virtual void onUnload() {};
    private:
        int mSize;
        bool mDepthTest;
    };

	class MAP_DATARENDER_EXPORT CPointRenderObject : public CRenderObject
	{
	public:
		CPointRenderObject(osg::ref_ptr<osg::Group> in_pParentNode);

		virtual ~CPointRenderObject();

		virtual osg::ref_ptr<osg::Vec3dArray>& getPoints();

		virtual osg::ref_ptr<osg::Vec4Array>& getColors();

		virtual bool getData(osg::ref_ptr<osg::Vec3dArray>& inou_points, osg::ref_ptr<osg::Vec4Array>& inout_colors);
	protected:
		virtual osg::ref_ptr<osg::Node> createNode(osg::ref_ptr<osg::Vec3dArray>& in_points, osg::ref_ptr<osg::Vec4Array>& in_colors);
	protected:
		osg::ref_ptr<osg::Vec3dArray> mpPoints;
		osg::ref_ptr<osg::Vec4Array> mpColors;
	};

	class MAP_DATARENDER_EXPORT CLineRenderObject : public CPointRenderObject
	{
	public:
		CLineRenderObject(osg::ref_ptr<osg::Group> in_pParentNode);

		virtual ~CLineRenderObject();

	protected:
		virtual osg::ref_ptr<osg::Node> createNode(osg::ref_ptr<osg::Vec3dArray>& in_points, osg::ref_ptr<osg::Vec4Array>& in_colors);
	};
}
#endif //_GENERALRENDEROBJECT_H